package cd.safe.school.bean;

import java.io.File;
import java.io.InputStream;
/**
 * 支持多个文件上传
 * @author wenzhang
 *
 */
public class FileItem {
	// 字段名称
	private String fieldName;
	// 文件名
	private String name;
	//文件类型
	private String contentType;
	// 记录文件路径
	private String path;
	//文件流信息（可以读取文件内容）
	private InputStream stream;
	public String getFieldName() {
		return fieldName;
	}
	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getContentType() {
		return contentType;
	}
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
	public String getPath() {
		return path;
	}
	public void setPath(String path) {
		this.path = path;
		File f=new File(path);
		//设置文件名
		setName(f.getName());
		//根据文件扩展名处理文件的ContentType
		if(name.endsWith(".txt")){
			setContentType("text/plain");
		}
		else if(name.endsWith(".jpg")||name.endsWith(".png")){
			setContentType("image/pjpeg");
		}
		else setContentType("application/octet-stream");//其余的用这个类型（不认识的文件）
	}
	public InputStream getStream() {
		return stream;
	}
	public void setStream(InputStream stream) {
		this.stream = stream;
	}
	
}
